// document.writeln('<meta name="viewport" content="width=device-width,initial-scale=1.0">')
function getQrcode(fingerPrint) {
    var arr = location.search.substr(1).split('&')
    var obj = {}
    for(var i = 0,len=arr.length;i<len;i++){
        var item = arr[i]
        var _arr = item.split('=')
        obj[ _arr[0] ] = _arr[1]
    }
    var a = obj['a'],b=obj['b'],c=decodeURIComponent(obj['c'])

    var ajaxObj=new XMLHttpRequest();
    ajaxObj.open("GET",c+"acitvecode/getActiveQrcode?codeId="+a+"&fingerPrint="+fingerPrint);
    ajaxObj.send()
    ajaxObj.onreadystatechange= function () {
        if(ajaxObj.readyState===4&&ajaxObj.status==200){
            var img = document.createElement('img')
            var bgimg = document.createElement('img')
            var result = JSON.parse(ajaxObj.response)
            var bgurl = c+result.data.bgurl
            bgimg.src = bgurl
            bgimg.className = "bgurl"
            img.src = 'data:image/png;base64,'+result.data.data
            img.setAttribute('style','width:100%;height:auto')
            document.body.appendChild(bgimg)
            document.body.getElementsByClassName('qrcode')[0].appendChild(img)
        }
    }

}

function getBrowserHash(fb){
    if (window.requestIdleCallback) {
        requestIdleCallback(function () {
            Fingerprint2.get(function (components) {
                var values = components.map(function (component) { return component.value })
                var murmur = Fingerprint2.x64hash128(values.join(''), 31)
                fb && fb(murmur)
            })
        })
    } else {
        setTimeout(function () {
            Fingerprint2.get(function (components) {
                var values = components.map(function (component) { return component.value })
                var murmur = Fingerprint2.x64hash128(values.join(''), 31)
                fb && fb(murmur)
            })
        }, 500)
    }
}

getBrowserHash(function (finger) {
    getQrcode(finger)
})
